<template>
  <div>
    <div style="margin-top: 20px;margin-left: 20px">
      <div class="firstdemo">
        <el-form ref="form" :model="importHeaders">
          <el-row type="flex" justify="start">
            <el-col :span="5">
              <el-form-item label="停车场id：" prop="park_id">
                <el-input v-model="importHeaders.park_id" size="small"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
    <div style="margin-top: 20px;margin-left: 20px">
      <el-button type="primary" @click="chakn()" v-loading.fullscreen.lock="fullscreenLoading">查看自己出入库信息</el-button>
      <el-dialog
          title="查看自己出入库"
          :visible.sync="dialogVisible"
          width="70%"
          :before-close="handleClose">
      <span>
        <el-table
            :data="tableData"
            style="width: 100%">
      <el-table-column
          prop="status"
          label="状态"
          width="180">
      </el-table-column>
      <el-table-column
          prop="platenumber"
          label="车牌号"
          width="180">
      </el-table-column>
      <el-table-column
          prop="add_time"
          label="时间">
      </el-table-column>
    </el-table>
      </span>
        <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
    </span>
      </el-dialog>
    </div>
    <div style="margin-left: 20px;margin-top: 20px">
      上传车牌照片
    </div>
    <el-upload
        action="http://127.0.0.1:8000/lot/upload/"
        list-type="picture-card"
        :auto-upload="true"
        :headers="importHeaders"
        :data="get_park_id"
        :on-success="jianting"
        :on-change="saijisja"
        >
      <i slot="default" class="el-icon-plus"></i>
      <div slot="file" slot-scope="{file}">
        <img
            class="el-upload-list__item-thumbnail"
            :src="file.url" alt=""
        >
        <span class="el-upload-list__item-actions">
        <span
            class="el-upload-list__item-preview"
            @click="handlePictureCardPreview(file)"
        >
          <i class="el-icon-zoom-in"></i>
        </span>
        <span
            v-if="!disabled"
            class="el-upload-list__item-delete"
            @click="handleDownload(file)"
        >
          <i class="el-icon-download"></i>
        </span>
        <span
            v-if="!disabled"
            class="el-upload-list__item-delete"
            @click="handleRemove(file)"
        >
          <i class="el-icon-delete"></i>
        </span>
      </span>
      </div>
    </el-upload>
    <el-dialog :visible.sync="dialogVisibles">
      <img width="100%" :src="dialogImageUrl" alt="">
    </el-dialog>
  </div>
</template>

<script>
export default {
name: "tingche",
  data() {
    return  {
      dialogVisible: false,
      tableData: [],
      dialogImageUrl: '',
      dialogVisibles: false,
      disabled: false,
      fullscreenLoading: false,
      importHeaders: {
        token: window.localStorage.getItem("token"),
        park_id: ''
      },
    };
  },
  methods: {
    get_park_id(){
      return this.importHeaders
    },
    chakn(){
      this.dialogVisible = true
      this.chakan()
    },
    async chakan(){
      const res = await this.$http.get('xinxi/', {
            params: {
              "token": window.localStorage.getItem("token")
            }
          }
      )
      this.tableData = res.data
    },
    handleClose(done) {
      this.$confirm('确认关闭？')
          .then(() => {
            done();
          })
          .catch(err => {
            console.log(err)});
    },
    handleRemove(file) {
      console.log(file);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisibles = true;
    },
    handleDownload(file) {
      console.log(file);
    },
    jianting(response){
      console.log(response)
      this.$notify({
        title: response.mes,
        message: response.info,
        type: 'success'
      });
      this.$message.success(response.mes)
    },
    saijisja(){
      this.fullscreenLoading = true;
      setTimeout(() => {
        this.fullscreenLoading = false;
      }, 3000);
    }
  }
}
</script>

<style scoped>

</style>
